//
//  SHTextField.m
//  YHSJ
//
//  Created by CYF on 16/11/10.
//  Copyright © 2016年 SH. All rights reserved.
//

#import "SHTextField.h"

@implementation SHTextField
-(instancetype)initWithFrame:(CGRect)frame{
    if ( self = [super initWithFrame:frame]) {
        
    }
    return self;
}

#pragma mark -- 设置lebel 文字 字体大小 16进制字体颜色  默认字体 默认字体大小 默认16进制字体颜色  是否密文 清除模式 样式 键盘类型
- (instancetype)labelText:(NSString *)text font:(CGFloat)font hexStringtextColor:(NSString *)textColor placeholder:(NSString *)placeholder placeholderFont:(CGFloat) placeholderFont placeholderHexStringtTextColor:(NSString *)placeholderTextColor secureTextEntry:(BOOL)secureTextEntry clearButtonMode:(UITextFieldViewMode)clearButtonMode borderStyle:(UITextBorderStyle)borderStyle keyboardType:(UIKeyboardType)keyboardType{
    
    [self labelText:textColor font:font textColor:KSETCOLORWITHHEXSTRING(textColor) placeholder:placeholder placeholderFont:placeholderFont placeholderTextColor:KSETCOLORWITHHEXSTRING(placeholderTextColor) secureTextEntry:secureTextEntry clearButtonMode:clearButtonMode borderStyle:borderStyle keyboardType:keyboardType];
    return self;
    
    
}

#pragma mark -- 设置lebel 文字 字体大小 字体颜色  默认字体 默认字体大小 默认字体颜色  是否密文 清除模式 样式 键盘类型
- (instancetype)labelText:(NSString *)text font:(CGFloat)font textColor:(UIColor *)textColor placeholder:(NSString *)placeholder placeholderFont:(CGFloat) placeholderFont placeholderTextColor:(UIColor *)placeholderTextColor secureTextEntry:(BOOL)secureTextEntry clearButtonMode:(UITextFieldViewMode)clearButtonMode borderStyle:(UITextBorderStyle)borderStyle keyboardType:(UIKeyboardType)keyboardType{
    
    [self setText:text font:font textColor:textColor];
    [self setPlaceholder:placeholder font:placeholderFont textColor:placeholderTextColor];
    self.secureTextEntry = secureTextEntry;
    self.clearButtonMode = clearButtonMode;
    self.borderStyle = borderStyle;
    self.keyboardType = keyboardType;
    
    return self;
}





#pragma mark -- 设置textField 圆角
- (void)setCornerRadius:(CGFloat)cornerRadius{
    self.layer.cornerRadius = __I6Width(cornerRadius);
    self.layer.masksToBounds = YES;
}
#pragma mark -- 设置textField 边框宽度 边框颜色
- (void)setBorderWidth:(CGFloat)borderWidth borderColor:(UIColor *)borderColor{
    self.layer.borderWidth = borderWidth;
    self.layer.borderColor = borderColor.CGColor;
}
#pragma mark - 设置textField text font textColor
- (void)setText:(NSString *)text font:(CGFloat)font textColorString:(NSString*)color{
    
    [self setText:text font:font textColor:[UIColor colorWithHexString:color]];
}
- (void)setText:(NSString *)text font:(CGFloat)font textColor:(UIColor *)color{
    
    [self setText:text];
    [self setFont:KSHSystemFont(font)];
    [self setTextColor:color];
    
}
#pragma mark - 设置textField placeholder font textColor
- (void)setPlaceholder:(NSString *)placeholder font:(CGFloat)font textColorString:(NSString *)color{
    
    [self setPlaceholder:placeholder font:font textColor:[UIColor colorWithHexString:color]];
}
- (void)setPlaceholder:(NSString *)placeholder font:(CGFloat)font textColor:(UIColor *)color{
    
    [self setPlaceholder:placeholder];
    [self  setValue:color forKeyPath:@"_placeholderLabel.textColor"];
    [self  setValue:KSHSystemFont(font) forKeyPath:@"_placeholderLabel.font"];
    
}

@end
